package com.rxyl.love.petdoctor.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.rxyl.love.petdoctor.R;
import com.rxyl.love.petdoctor.entity.HospitalComment;

import java.util.List;

/**
 * Created by dd on 2016/1/21 0021.
 */
public class CommentListAdapter extends BaseAdapter {
    private Context context;
    private List<HospitalComment.DataEntity.ListEntity> commentList;

    public CommentListAdapter(Context context, List<HospitalComment.DataEntity.ListEntity> comment) {
        this.context = context;
        this.commentList = comment;
    }

    @Override
    public int getCount() {
        return commentList.size();
    }

    @Override
    public Object getItem(int position) {
        return commentList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.adapter_layout_commentlist, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_comment_name);
            viewHolder.tv_content = (TextView) convertView.findViewById(R.id.tv_comment_content);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv_name.setText(commentList.get(position).getNickname());
        viewHolder.tv_content.setText(commentList.get(position).getContent());
        return convertView;
    }

    class ViewHolder {
        TextView tv_name, tv_content;
    }
}
